//
//  dvdPopView.m
//  GBKHOME
//
//  Created by XMYY-19 on 2017/9/7.
//
//

#import "dvdPopView.h"
#import "LoginController1.h"

@interface dvdPopView ()
- (IBAction)closedBtnClick:(UIButton *)sender;
- (IBAction)TVClick:(UIButton *)sender;
- (IBAction)ACClick:(UIButton *)sender;
- (IBAction)AUXClick:(UIButton *)sender;
- (IBAction)DBClick:(UIButton *)sender;
- (IBAction)zhishiBtnClick:(UIButton *)sender;
- (IBAction)zidingyiClick:(UIButton *)sender;
- (IBAction)setBtnClick:(UIButton *)sender;
- (IBAction)shengdaoBtnClick:(UIButton *)sender;
- (IBAction)stopBtnClick:(UIButton *)sender;

@end


@implementation dvdPopView

//-(instancetype)initWithCoder:(NSCoder *)aDecoder
//{
//    if (self = [super initWithCoder:aDecoder]) {
//        UIView *view = [[[NSBundle mainBundle]loadNibNamed:@"dvdPopView" owner:self options:nil]objectAtIndex:0];
//        [self addSubview:view];
//    }
//    return self;
//}

#pragma mark--点击关闭
- (IBAction)closedBtnClick:(UIButton *)sender {
    [UIView animateWithDuration:0.2 animations:^{
        self.frame = CGRectMake(0, 450, 375, 667);
    }];
}

- (IBAction)TVClick:(UIButton *)sender {
    
     [self ctrDVD:@"TV"];
}
#pragma mark - 控制DVD
- (void)ctrDVD:(NSString *)ORDER
{
    NSString *order = ORDER;
    NSString *orderName = NSLocalizedString(order, nil);
    NSString *operat = NSLocalizedString(@"operat:", nil);
    NSString *startTip = [operat stringByAppendingString:orderName];
    [iToast showTip:startTip gravity:iToastGravityBottom];
    
    [WebServices setShowConnectting:NO];
    
    self.ctrOrder = order;
      NSString *switchId = @"15";
   // NSString *switchId = self.equipment.switchId;
    NSString *sessionId = [LoginController1 sessionID];
    NSString *fomat = @"[{\"orderId\":\"%@\", \"switchId\":\"%@\", \"sessionId\":\"%@\"}]";
    NSString *body = [NSString stringWithFormat:fomat, order, switchId, sessionId];
    
    //操作失败！原因：
    NSString *errorTip = [OperationTip operatSuccess:NO type:ErrorTypeNetworkFail];
    [WebServices requestStartOrder:@"ctlDVD" body:body target:self action:@selector(ctrDVDEnd:) errorTip:errorTip];
}
- (void)ctrDVDEnd:(NSDictionary *)dic
{
    NSLog(@"%@", dic);
    NSNumber *result = [dic objectForKey:@"result"];
    if (result.integerValue == 0) {
        //操作成功
        NSString *tip = [OperationTip operatSuccess:YES type:ErrorTypeServerReturnFail];
        [iToast showTip:tip gravity:iToastGravityBottom];
    }
    else
    {
        //操作失败！原因：
        NSString *tip = [OperationTip operatSuccess:NO type:ErrorTypeServerReturnFail];
        [iToast showTip:tip gravity:iToastGravityBottom];
    }
}
- (IBAction)ACClick:(UIButton *)sender {
     [self ctrDVD:@"AC-3"];
}

- (IBAction)AUXClick:(UIButton *)sender {
    
     [self ctrDVD:@"AUX"];
}

- (IBAction)DBClick:(UIButton *)sender {
    [self ctrDVD:@"BD"];
}

- (IBAction)zhishiBtnClick:(UIButton *)sender
{
}
- (IBAction)zidingyiClick:(UIButton *)sender {
}

- (IBAction)setBtnClick:(UIButton *)sender {
       [self ctrDVD:@"SET"];
}

- (IBAction)shengdaoBtnClick:(UIButton *)sender {
}

- (IBAction)stopBtnClick:(UIButton *)sender {
}
@end
